package com.chery.media.library.picture

import com.blankj.utilcode.util.Utils
import com.chery.media.library.R.*
import com.chery.media.library.extend.toColorInt
import com.chery.media.library.extend.toResString
import com.luck.picture.lib.style.BottomNavBarStyle
import com.luck.picture.lib.style.PictureSelectorStyle
import com.luck.picture.lib.style.SelectMainStyle
import com.luck.picture.lib.style.TitleBarStyle
import com.luck.picture.lib.utils.DensityUtil

/**
* 描述：图片选择配置
*/
object PictureSelectionConfig {

    val pictureSelectorUIStyle by lazy {
        PictureSelectorStyle().apply {
            // 微信风格
            titleBarStyle = wxTitleBarStyle()
            bottomBarStyle = wxBottomNavBarStyle()
            selectMainStyle = wxMainStyle()
        }
    }

    /**
     *  头部TitleBar 风格
     */
    private fun wxTitleBarStyle(): TitleBarStyle {
        return TitleBarStyle().apply {
            isHideCancelButton = true
            isAlbumTitleRelativeLeft = true
            titleAlbumBackgroundResource = drawable.ps_album_bg
            titleDrawableRightResource = drawable.ps_ic_grey_arrow
            previewTitleLeftBackResource = drawable.ps_ic_normal_back
        }
    }

    /**
     *  底部NavBar 风格
     */
    private fun wxBottomNavBarStyle(): BottomNavBarStyle {
        return BottomNavBarStyle().apply {
            bottomPreviewNarBarBackgroundColor = color.ps_color_half_grey.toColorInt()
            bottomPreviewNormalText = string.ps_preview.toResString()
            bottomPreviewNormalTextColor = color.ps_color_9b.toColorInt()
            bottomPreviewNormalTextSize = 16
            isCompleteCountTips = false
            bottomPreviewSelectText = Utils.getApp().getString(string.ps_preview_num)
            bottomPreviewSelectTextColor = color.public_FFFFFF.toColorInt()
        }
    }

    /**
     * 主体风格
     */
    private fun wxMainStyle(): SelectMainStyle {
        // 主体风格
        return SelectMainStyle().apply {
            isSelectNumberStyle = true
            isPreviewSelectNumberStyle = false
            isPreviewDisplaySelectGallery = true
            selectBackground = drawable.ps_default_num_selector
            previewSelectBackground = drawable.ps_preview_checkbox_selector
            selectNormalBackgroundResources = drawable.ps_select_complete_normal_bg
            selectNormalTextColor = color.ps_color_53575e.toColorInt()
            selectNormalText = string.ps_send.toResString()
            adapterPreviewGalleryBackgroundResource = drawable.ps_preview_gallery_bg
            adapterPreviewGalleryItemSize = DensityUtil.dip2px(Utils.getApp(), 52f)
            previewSelectText = string.ps_select.toResString()
            previewSelectTextSize = 14
            previewSelectTextColor = color.public_FFFFFF.toColorInt()
            previewSelectMarginRight = DensityUtil.dip2px(Utils.getApp(), 6f)
            selectBackgroundResources = drawable.ps_select_complete_bg
            selectText = Utils.getApp().getString(string.ps_send_num)
            selectTextColor = color.public_FFFFFF.toColorInt()
            mainListBackgroundColor = color.ps_color_black.toColorInt()
            isCompleteSelectRelativeTop = true
            isPreviewSelectRelativeBottom = true
            isAdapterItemIncludeEdge = false
        }
    }
}